//
//  DoctorApplicationCell.m
//  QuickCure1
//
//  Created by summer的Dad on 16/10/31.
//  Copyright © 2016年 maoge. All rights reserved.
//

#import "DoctorApplicationCell.h"
#import "DoctorApplyListModel.h"
@interface DoctorApplicationCell()

@property (weak, nonatomic)  UILabel *leb_qualified;

@property (weak, nonatomic)  UILabel *leb_disease;

@property (weak, nonatomic)  UILabel *leb_time;
@property (weak, nonatomic)  UILabel *leb_doctorName;
@property (weak, nonatomic) UILabel *leb_hospital;



@end
#define defaultPadding 5
#define sizeCellWidth 310
#define sizeCellHeight 90
#define sizePicture 50
#define sizeTitleWidth 200
#define sizeTitleheight 20


@implementation DoctorApplicationCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
 
        [self setupUI];
 
    }
    
    return self;
    
}

- (void)setupUI
{
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(defaultPadding, defaultPadding,
                                                              sizeCellWidth, sizeCellHeight)];
//    bgView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1];
    [self.atcContentView addSubview:bgView];

    
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.top.equalTo(self).offset(5);
        make.trailing.bottom.equalTo(self).offset(-5);
        
    }];
    
    
    //老王
    UILabel* title_user = [[UILabel alloc] init];
    title_user.text = @"老王";
    [bgView addSubview:title_user];
    [title_user mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.top.equalTo(bgView).offset(8);
    }];
//    //时间
    UILabel* title_time = [[UILabel alloc] init];
    
    self.leb_time = title_time;
    
    title_time.font= [UIFont boldSystemFontOfSize:14];
    
    title_time.textColor= [UIColor colorWithWhite:0.8 alpha:1];
    [bgView addSubview:title_time];
    [title_time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(title_user.mas_centerY);
        make.width.offset(230);
        make.height.offset(20);
        make.leading.equalTo(title_user.mas_trailing).offset(4);
    }];
        [self setTime];

//    //医生名字
    UILabel* leb_name = [[UILabel alloc] init];
    leb_name.text = @"老中医";
    self.leb_doctorName = leb_name;
    [bgView  addSubview:leb_name];
    [leb_name  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(title_user.mas_bottom).offset(40);
        make.height.equalTo(@20);
//        make.width.offset(50);
        make.leading.equalTo(title_user.mas_leading);
        make.bottom.equalTo(bgView.mas_bottom).offset(-8);
        
    }];
    //主任医师
    UILabel* leble_doctor =[[UILabel alloc] init];
    leble_doctor.text = @"主任医师";
    [bgView addSubview:leble_doctor];
    leble_doctor.font= [UIFont boldSystemFontOfSize:14];
    
    leble_doctor.textColor = [UIColor colorWithWhite:0.8 alpha:1];
    [leble_doctor mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(leb_name.mas_trailing).offset(8);
        make.bottom.equalTo(bgView).offset(-8);
    }];
//    //医院
    UILabel* leb_hospital = [[UILabel alloc] init];
    leb_hospital.text = @"精神医院";
    leb_hospital.font= [UIFont boldSystemFontOfSize:14];
    self.leb_hospital = leb_hospital;
    leb_hospital.textColor = [UIColor colorWithWhite:0.8 alpha:1];
    [bgView addSubview:leb_hospital];
    [leb_hospital mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(leble_doctor.mas_trailing).offset(8);
        make.bottom.equalTo(bgView).offset(-8);
    }];
    //审核
    UILabel* leb_check = [[UILabel alloc] init];
    self.leb_qualified = leb_check;
    leb_check.textColor = [UIColor colorWithWhite:0.7 alpha:1];
    leb_check.textAlignment = NSTextAlignmentCenter;
    [bgView addSubview:leb_check];
    [leb_check mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(bgView.mas_centerY);
        make.trailing.equalTo(bgView).offset(-8);
        make.height.width.offset(55);
    }];
    self.leb_qualified.layer.cornerRadius = 27.5;
    self.leb_qualified.layer.masksToBounds = YES;
    
    

}

#pragma mark
#pragma mark - model赋值



-(void)setModel:(DoctorApplyListModel *)model
{
    _model = model;
    
    if ([MLDefaults boolForKey:model.doctor_portrait])
    {
        self.leb_qualified.text = @"审核中";
        self.leb_qualified.backgroundColor = [UIColor colorWithRed:121/255.0 green:253/255.0 blue:254/255.0 alpha:1];
        
    }
    else
    {
        self.leb_qualified.text = @"审核";
        self.leb_qualified.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
    }
    self.leb_doctorName.text = model.doctor_name;
    self.leb_hospital.text = model.doctor_hospital_name;
    self.leb_disease.text = model.title_name;

}


#pragma mark
#pragma mark - 入口
- (void)awakeFromNib {
    [super awakeFromNib];
  

}
#pragma mark
#pragma mark - 设置时间
- (void)setTime
{

 //获取当前时间日期
 NSDate *date=[NSDate date];
 NSDateFormatter *format1=[[NSDateFormatter alloc] init];

 //拿到时间数据

        [format1 setDateFormat:@"预约时间:yyyy-MM-dd HH:mm:ss"];
        //拿到时间数据
        
        
        NSString *dateStr;
        dateStr=[format1 stringFromDate:date];
        self.leb_time.text = dateStr;
        
    
}

#pragma mark
#pragma mark - 画线
- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetLineCap(context, kCGLineCapRound);
    CGContextSetLineWidth(context, 3);  //线宽
    CGContextSetAllowsAntialiasing(context, true);
    CGContextSetRGBStrokeColor(context, 70.0 / 255.0, 241.0 / 255.0, 241.0 / 255.0, 1.0);  //线的颜色
    CGContextBeginPath(context);
    
    CGContextMoveToPoint(context, 10, 50);  //起点坐标
    CGContextAddLineToPoint(context, 250, 50);
    CGContextAddLineToPoint(context, 260, 60);
    CGContextAddLineToPoint(context, 270, 30);
    CGContextAddLineToPoint(context, 285, 50);
    
    CGContextAddLineToPoint(context, 340, 50);   //终点坐标
    
    CGContextStrokePath(context);
    
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
